<?php
namespace Summer\Sms\Classes;

use Illuminate\Support\Carbon;
use Overtrue\EasySms\Contracts\MessageInterface;
use Overtrue\EasySms\Contracts\PhoneNumberInterface;
use Overtrue\EasySms\Gateways\Gateway;
use Overtrue\EasySms\Support\Config;
use Overtrue\EasySms\Traits\HasHttpRequest;
use Log;
class IpyyGateway extends Gateway
{

    use HasHttpRequest;

    const ENDPOINT_HOST = 'https://dx.ipyy.net/sms.aspx';

    const ENDPOINT_URI = '';

    protected $api_key;

    protected $api_secret;

    protected $sign = null;

    protected $client;

    /**
     * Send a short message.
     *
     * @param \Overtrue\EasySms\Contracts\PhoneNumberInterface $to
     * @param \Overtrue\EasySms\Contracts\MessageInterface $message
     * @param \Overtrue\EasySms\Support\Config $config
     *
     * @return array
     */
    public function send(PhoneNumberInterface $to, MessageInterface $message, Config $config)
    {
        $params = [
            'action' => 'send',
            'userid'=>'',
            'account'=>$config->get('api_key'),
            'password'=>$config->get('api_secret'),
            'mobile'=>$to->getNumber(),
            'extno'=>'',
            'content'=>'【' . $config->get('sign') . '】'.$message->getContent(),
            'sendtime'=>Carbon::now()
        ];
        $res=$this->post(self::ENDPOINT_HOST, $params);
        return $res;
    }

    protected function getBaseUri()
    {
        return self::ENDPOINT_HOST;
    }


}
